package doublepoint;

/**
 * @Author: 海琳琦
 * @Date: 2022/2/3 2:21
 * https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/
 */
public class RemoveDuplicates {

    public int removeDuplicates(int[] nums) {
        int firstIndex = 0;
        for (int endIndex = 1; endIndex < nums.length; endIndex++) {
            if (nums[firstIndex] != nums[endIndex]) {
                firstIndex++;
                nums[firstIndex] = nums[endIndex];
            }
        }
        return firstIndex + 1;
    }

    public static void main(String[] args) {

    }
}
